package com.houweishi.module.clockedtype.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.houweishi.common.annotation.Log;
import com.houweishi.common.core.controller.BaseController;
import com.houweishi.common.core.domain.AjaxResult;
import com.houweishi.common.enums.BusinessType;
import com.houweishi.module.clockedtype.domain.BizClockedType;
import com.houweishi.module.clockedtype.service.IBizClockedTypeService;
import com.houweishi.common.utils.poi.ExcelUtil;
import com.houweishi.common.core.page.TableDataInfo;

/**
 * 打卡模型Controller
 * 
 * @author houweishi
 * @date 2023-03-02
 */
@RestController
@RequestMapping("/module/clockedtype")
public class BizClockedTypeController extends BaseController
{
    @Autowired
    private IBizClockedTypeService bizClockedTypeService;

    /**
     * 查询打卡模型列表
     */
//    @PreAuthorize("@ss.hasPermi('module:clockedtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizClockedType bizClockedType)
    {
        startPage();
        List<BizClockedType> list = bizClockedTypeService.selectBizClockedTypeList(bizClockedType);
        return getDataTable(list);
    }

    /**
     * 导出打卡模型列表
     */
    @PreAuthorize("@ss.hasPermi('module:clockedtype:export')")
    @Log(title = "打卡模型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BizClockedType bizClockedType)
    {
        List<BizClockedType> list = bizClockedTypeService.selectBizClockedTypeList(bizClockedType);
        ExcelUtil<BizClockedType> util = new ExcelUtil<BizClockedType>(BizClockedType.class);
        util.exportExcel(response, list, "打卡模型数据");
    }

    /**
     * 获取打卡模型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('module:clockedtype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizClockedTypeService.selectBizClockedTypeById(id));
    }

    /**
     * 新增打卡模型
     */
    @PreAuthorize("@ss.hasPermi('module:clockedtype:add')")
    @Log(title = "打卡模型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizClockedType bizClockedType)
    {
        return toAjax(bizClockedTypeService.insertBizClockedType(bizClockedType));
    }

    /**
     * 修改打卡模型
     */
    @PreAuthorize("@ss.hasPermi('module:clockedtype:edit')")
    @Log(title = "打卡模型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizClockedType bizClockedType)
    {
        return toAjax(bizClockedTypeService.updateBizClockedType(bizClockedType));
    }

    /**
     * 删除打卡模型
     */
    @PreAuthorize("@ss.hasPermi('module:clockedtype:remove')")
    @Log(title = "打卡模型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizClockedTypeService.deleteBizClockedTypeByIds(ids));
    }
}
